﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using EventAggregationQuickStart;

namespace ModuleA
{
    public partial class ModuleAView : UserControl, IModuleAView
    {
        public ModuleAView()
        {
            InitializeComponent();
        }

        #region IView<ModuleAPresenter> Members

        public ModuleAPresenter Presenter
        {
            get; set;
        }

        #endregion


        #region IModuleAView Members

        // Necessary because .NET CF does not support full framework MethodInvoker
        private delegate void MethodInvoker();

        public void ShowDataFromEvent(int intData)
        {
            if (this.InvokeRequired)
            {
                this.Invoke(
                    (MethodInvoker)delegate()
                    {
                        this.lblEventData.Text = "Event Data: " + intData.ToString();
                    }
                );
            }
            else
            {
                this.lblEventData.Text = "Event Data: " + intData.ToString();
            }
        }

        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
            Presenter.Button1ActionRequested();
        }
    }
}
